﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class lop_bcquangduongxechay
    {
        string Mxe,Tenduong;
        int Sokmchay,Xangtieuthu,Thoigiandung;
        DateTime Ngaychay;
        public lop_bcquangduongxechay(){}
        public lop_bcquangduongxechay(string Mxe,string Tenduong, int Sokmchay,int Xangtieuthu,int Thoigiandung,DateTime Ngaychay)
        {
            this.Mxe = Mxe;
            this.Tenduong = Tenduong;
            this.Sokmchay = Sokmchay;
            this.Xangtieuthu = Xangtieuthu;
            this.Thoigiandung = Thoigiandung;
            this.Ngaychay = Ngaychay;
        }
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into bcquangduongxechay values ('" + Mxe + "',N'" + Tenduong + "','" + Sokmchay + "','" + Xangtieuthu + "','" + Thoigiandung + "','" + Ngaychay + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update bcquangduongxechay set Tenduong=N'" + Tenduong + "',Sokmchay='" + Sokmchay + "',Xangtieuthu='" + Xangtieuthu + "',Thoigiandung='" + Thoigiandung + "',Ngaychay='" + Ngaychay + "' where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from bcquangduongxechay where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
